package com.work.music.dao;

import com.work.music.entity.Integral;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

@Repository
public interface IntegralMapper {
    @Delete({
        "delete from music_integral",
        "where uid = #{uid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long uid);

    @Insert({
        "insert into music_integral (uid, useintegral, ",
        "totalintegral)",
        "values (#{uid,jdbcType=BIGINT}, #{useintegral,jdbcType=BIGINT}, ",
        "#{totalintegral,jdbcType=BIGINT})"
    })
    int insert(Integral record);

    @Select({
        "select",
        "uid, useintegral, totalintegral",
        "from music_integral",
        "where uid = #{uid,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="useintegral", property="useintegral", jdbcType=JdbcType.BIGINT),
        @Result(column="totalintegral", property="totalintegral", jdbcType=JdbcType.BIGINT)
    })
    Integral selectByPrimaryKey(Long uid);

    @Select({
        "select",
        "uid, useintegral, totalintegral",
        "from music_integral"
    })
    @Results({
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="useintegral", property="useintegral", jdbcType=JdbcType.BIGINT),
        @Result(column="totalintegral", property="totalintegral", jdbcType=JdbcType.BIGINT)
    })
    List<Integral> selectAll();

    @Update({
        "update music_integral",
        "set useintegral = #{useintegral,jdbcType=BIGINT},",
          "totalintegral = #{totalintegral,jdbcType=BIGINT}",
        "where uid = #{uid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Integral record);
}